<?php
namespace Admin\Controller;
use Think\Controller;
use Admin\Controller\CommonController;
class CategoryController extends CommonController {
	public function categorylistAction()
	{
		$sql = "select * from category";
		$res = M()->query($sql);
		S('categorydata',$res,300);

		// var_dump($res);
		// 分类树
		$obj = new Tree();
		$res = $obj->run($res);
		// var_dump($res);exit;
		$this->assign('res',$res);
		$this->display();
		
	}

	public function indexAction()
	{
		$sql = "select * from category";
		$res = M()->query($sql);

		// var_dump($res);
		// 分类树
		$obj = new Tree();
		$res = $obj->run1($res);
		// echo "<pre>";
		// print_r($res);
		// echo "<pre>";
		// exit;
		$this->assign('res',$res);
		$this->display();
		
	}

	public function addAction()
	{
		$data = I('post.');
		$id = M('category')->add($data);

		if($id){
			$this->success('增加成功l',U('admin/category/categorylist'));
		}
	}
}